home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / dfunclib.lha / dfunc_library / includes / Startup.i < prev   
Text File  |  1995-04-26  |  1KB  |  39 lines

  1.     *----------------------------------------------------------------------
  2.     *
  3.     *    Startup code rewritten and optimized by K.C. Nilsen.
  4.     *
  5.     *    Do not need any includes.
  6.     *    Use this in the beginning of your source (1.label called Start)
  7.     *    This routine makes programs work fine even if they where
  8.     *    started from Workbench (Icon...).
  9.     *
  10.     *----------------------------------------------------------------------
  11.  
  12. StartUp    movem.l    d0/a0,-(sp)
  13.     lea    $0.w,a1
  14.     move.l    $4.w,a6
  15.     jsr    -294(a6)            find task (this task)
  16.     move.l    d0,a4
  17.     tst.l    172(a4)                test if started from CLI 
  18.     beq.b    .WB                was launched from Workbench
  19.     movem.l    (sp)+,d0/a0
  20.     bra.b    .End
  21. .WB    lea    92(a4),a0            message port
  22.     jsr    -384(a6)            wait port
  23.     lea    92(a4),a0
  24.     jsr    -372(a6)            get message
  25.     move.l    d0,RtnMess
  26.     movem.l    (sp)+,d0/a0
  27.  
  28. .End    bsr.w    Start                start our program
  29.     move.l    d0,-(sp)
  30.     tst.l    RtnMess                any message ?
  31.     beq.w    .DOS                no > exit to DOS
  32.     move.l    $4.w,a6
  33.     jsr    -132(a6)            forbid
  34.     move.l    RtnMess(pc),a1            give back message pointer
  35.     jsr    -138(a6)            permit
  36. .DOS    move.l    (sp)+,d0
  37.     rts                    exit to DOS
  38. RtnMess    dc.l    0
  39.